{% extends 'index/base.html' %}

{% block title %}聚合热点新闻{% endblock %}

{% block content %}
  <section class="card wow fadeIn" style="background-image: url({{ url_for('static',filename='img/gradient1.jpg') }});">
    <div class="card-body text-white text-center py-5 px-5 my-5">
      <h1 class="mb-4">
        <strong>聚合热点导航</strong>
      </h1>
      <p>
        <strong>每日最新资讯，一个网站，全部掌握！</strong>
      </p>
      <p class="mb-4">
        <strong>上班摸鱼，厕所学习，睡前浏览必备神器！</strong>
      </p>
      {% if not current_user.is_authenticated %}
        <a target="_blank" href="{{ url_for('auth.login') }}" class="btn btn-outline-white btn-lg">登陆后可自由添加订阅
            <i class="fas fa-graduation-cap ml-2"></i>
        </a>
      {% else %}
        <a class="btn btn-outline-white btn-lg" href="{{ url_for('auth.index') }}">个人中心
            <i class="fas fa-user ml-2"></i>
        </a>
      {% endif %}
    </div>
  </section>
  <hr class="my-5">

  <section>
    <div class="row mb-4 wow fadeIn">
      {% if not current_user.is_authenticated %}
        {% for subscribe in subscribes %}
          <div class="col-lg-4 col-md-12 mb-4">
            <div class="card">
              <div class="view overlay">
                  <img src="{{ url_for('poly.get_cover', filename=subscribe.image) }}" class="card-img-top"  width="350" height="180">
                <a href="#">
                  <div class="mask rgba-white-slight"></div>
                </a>
              </div>
              <div class="card-body">
                <h4 class="card-title text-center">{{ subscribe.name }}</h4>
                <!--Text-->
                {% for record in subscribe.records[:5] %}
                  <a class="card-text" target="_blank" style="line-height:30px" href="{{ record.url }}">{{ record.title|truncate(20, killwords=True, leeway=0) }}</a><br>
                {% endfor %}
                <div class="text-center">
                  <a href="{{ url_for('poly.detail', crawler_id=subscribe.id) }}" target="_blank"
                    class="btn btn-primary btn-md text">查看更多
                    <i class="fas fa-play ml-2"></i>
                  </a>
                </div>
              </div>
            </div>
          </div>
        {% endfor %}
      {% elif current_user.subscription %}
        {% for subscribe in current_user.subscription %}
          <div class="col-lg-4 col-md-12 mb-4">
            <div class="card">
              <div class="view overlay">
                  <img src="{{ url_for('poly.get_cover', filename=subscribe.subscribed.image) }}" class="card-img-top" alt="">
                <a href="#">
                  <div class="mask rgba-white-slight"></div>
                </a>
              </div>
              <div class="card-body">
                <h4 class="card-title text-center">{{ subscribe.subscribed.name }}</h4>
                <!--Text-->
                {% for record in subscribe.subscribed.records[-5::] %}
                  <p class="card-text" href="{{ record.url }}">{{ record.title|truncate(20, killwords=True, leeway=0) }}</p>
                {% endfor %}
                <div class="text-center">
                  <a href="{{ url_for('poly.detail', crawler_id=subscribe.subscribed.id) }}" target="_blank"
                    class="btn btn-primary btn-md text">查看更多
                    <i class="fas fa-play ml-2"></i>
                  </a>
                </div>
              </div>
            </div>
          </div>
        {% endfor %}
      {% else %}
          <div class="container card">
              <div class="card-body text-center">
                  还没有订阅，快去<a href="{{ url_for('poly.market') }}">订阅市场</a>添加几个吧
              </div>
          </div>
      {% endif %}
    </div>
  </section>
{% endblock %}